<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>GSoC2011SfM: D:/Travail/These/Determination caracteristiques camera/GSoC/SfM/src/PointsToTrack.cpp Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">GSoC2011SfM
   &#160;<span id="projectnumber">0.1</span>
   </div>
   <div id="projectbrief">Google Summer of Code 2011: Structure from motion</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">D:/Travail/These/Determination caracteristiques camera/GSoC/SfM/src/PointsToTrack.cpp</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &quot;PointsToTrack.h&quot;</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &quot;TracksOfPoints.h&quot;</span>
<a name="l00003"></a>00003 
<a name="l00004"></a>00004 <span class="keyword">using</span> cv::Mat;
<a name="l00005"></a>00005 <span class="keyword">using</span> cv::Scalar;
<a name="l00006"></a>00006 <span class="keyword">using</span> cv::KeyPoint;
<a name="l00007"></a>00007 <span class="keyword">using</span> cv::Point;
<a name="l00008"></a>00008 <span class="keyword">using</span> std::vector;
<a name="l00009"></a>00009 <span class="keyword">using</span> cv::line;
<a name="l00010"></a>00010 <span class="keyword">using</span> cv::circle;
<a name="l00011"></a>00011 
<a name="l00012"></a>00012 <span class="keyword">namespace </span>OpencvSfM{
<a name="l00013"></a>00013   <span class="keywordtype">int</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#abb10da9503a8ac931d9d167149309df3" title="total numbers of images!">PointsToTrack::glob_number_images_</a> = 0;
<a name="l00014"></a>00014 
<a name="l00015"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a81706fbb7c997cbfd478397a5e7b3dc7">00015</a>   <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a81706fbb7c997cbfd478397a5e7b3dc7">PointsToTrack::PointsToTrack</a>( <span class="keywordtype">int</span> corresponding_image,
<a name="l00016"></a>00016     std::vector&lt;KeyPoint&gt; keypoints, Mat descriptors )
<a name="l00017"></a>00017     :keypoints_( keypoints ),descriptors_( descriptors )
<a name="l00018"></a>00018   {
<a name="l00019"></a>00019     <span class="keywordflow">if</span> ( corresponding_image&gt;=0 )
<a name="l00020"></a>00020       <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#aa1ad5a647af1dd6583dbd780e94c089c" title="index of frame when available">corresponding_image_</a> = corresponding_image;
<a name="l00021"></a>00021     <span class="keywordflow">else</span>
<a name="l00022"></a>00022       <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#aa1ad5a647af1dd6583dbd780e94c089c" title="index of frame when available">corresponding_image_</a> = <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#abb10da9503a8ac931d9d167149309df3" title="total numbers of images!">PointsToTrack::glob_number_images_</a>;
<a name="l00023"></a>00023 
<a name="l00024"></a>00024     <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#abb10da9503a8ac931d9d167149309df3" title="total numbers of images!">PointsToTrack::glob_number_images_</a>++;
<a name="l00025"></a>00025     <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a52d852bc3fa39c952405c55a8d1e378f">nb_workers_</a> = 0;
<a name="l00026"></a>00026     INIT_MUTEX(worker_exclusion);
<a name="l00027"></a>00027   }
<a name="l00028"></a>00028 
<a name="l00029"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a68187dd20979c51cef7dad01116f5c94">00029</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a68187dd20979c51cef7dad01116f5c94">PointsToTrack::free_descriptors</a>()
<a name="l00030"></a>00030   {
<a name="l00031"></a>00031     P_MUTEX(worker_exclusion);
<a name="l00032"></a>00032     <span class="keywordflow">if</span>(<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a52d852bc3fa39c952405c55a8d1e378f">nb_workers_</a>&lt;=1)
<a name="l00033"></a>00033     {<span class="comment">//if equal to 0, descriptors_ is already empty...</span>
<a name="l00034"></a>00034       <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a52d852bc3fa39c952405c55a8d1e378f">nb_workers_</a> = 0;
<a name="l00035"></a>00035       <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adcbf3783bdf4a2a1d3e10c4b74224899">descriptors_</a>.release( );
<a name="l00036"></a>00036     }
<a name="l00037"></a>00037     <span class="keywordflow">else</span>
<a name="l00038"></a>00038       <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a52d852bc3fa39c952405c55a8d1e378f">nb_workers_</a>--;
<a name="l00039"></a>00039     V_MUTEX(worker_exclusion);
<a name="l00040"></a>00040   }
<a name="l00041"></a>00041 
<a name="l00042"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a530e94d0c39358538d907e977263cae0">00042</a>   <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a530e94d0c39358538d907e977263cae0">PointsToTrack::~PointsToTrack</a>( <span class="keywordtype">void</span> )
<a name="l00043"></a>00043   {
<a name="l00044"></a>00044     <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>.clear( );
<a name="l00045"></a>00045     <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adcbf3783bdf4a2a1d3e10c4b74224899">descriptors_</a>.release( );
<a name="l00046"></a>00046     <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#abb10da9503a8ac931d9d167149309df3" title="total numbers of images!">PointsToTrack::glob_number_images_</a>--;
<a name="l00047"></a>00047   }
<a name="l00048"></a>00048   
<a name="l00049"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a9f310ef736a0494457ee9f2193b8b986">00049</a>   <span class="keywordtype">int</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a9f310ef736a0494457ee9f2193b8b986">PointsToTrack::computeKeypointsAndDesc</a>( <span class="keywordtype">bool</span> forcing_recalculation )
<a name="l00050"></a>00050   {
<a name="l00051"></a>00051     P_MUTEX(worker_exclusion);
<a name="l00052"></a>00052     <span class="keywordflow">if</span>( !forcing_recalculation )
<a name="l00053"></a>00053     {
<a name="l00054"></a>00054       <span class="keywordtype">bool</span> need_keypoints = <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>.empty( );
<a name="l00055"></a>00055       <span class="keywordtype">bool</span> need_descriptors = need_keypoints || <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adcbf3783bdf4a2a1d3e10c4b74224899">descriptors_</a>.empty( );
<a name="l00056"></a>00056       <span class="keywordflow">if</span>( need_keypoints )
<a name="l00057"></a>00057         <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#add21f430e246d2176dee8a34d4b92ead">impl_computeKeypoints_</a>();
<a name="l00058"></a>00058       <span class="keywordflow">if</span>( need_descriptors )
<a name="l00059"></a>00059       {
<a name="l00060"></a>00060         CV_Assert( <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a52d852bc3fa39c952405c55a8d1e378f">nb_workers_</a> == 0 );
<a name="l00061"></a>00061         <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a086c4acf6884db7487eb05f9c3d996a3">impl_computeDescriptors_</a>();
<a name="l00062"></a>00062       }
<a name="l00063"></a>00063       <span class="keywordflow">else</span>
<a name="l00064"></a>00064         <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a52d852bc3fa39c952405c55a8d1e378f">nb_workers_</a>++;
<a name="l00065"></a>00065     }
<a name="l00066"></a>00066     <span class="keywordflow">else</span>
<a name="l00067"></a>00067     {
<a name="l00068"></a>00068       <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#add21f430e246d2176dee8a34d4b92ead">impl_computeKeypoints_</a>();
<a name="l00069"></a>00069       <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a086c4acf6884db7487eb05f9c3d996a3">impl_computeDescriptors_</a>();
<a name="l00070"></a>00070     }
<a name="l00071"></a>00071 
<a name="l00072"></a>00072     V_MUTEX(worker_exclusion);
<a name="l00073"></a>00073     <span class="keywordflow">return</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>.size( );
<a name="l00074"></a>00074   }
<a name="l00075"></a>00075 
<a name="l00076"></a>00076 
<a name="l00077"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#ac7009164560dac1f4d3283c4bf1181a3">00077</a>   <span class="keywordtype">int</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#ac7009164560dac1f4d3283c4bf1181a3">PointsToTrack::computeKeypoints</a>( )
<a name="l00078"></a>00078   {
<a name="l00079"></a>00079     P_MUTEX(worker_exclusion);
<a name="l00080"></a>00080     <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#add21f430e246d2176dee8a34d4b92ead">impl_computeKeypoints_</a>();
<a name="l00081"></a>00081     V_MUTEX(worker_exclusion);
<a name="l00082"></a>00082     <span class="keywordflow">return</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>.size( );
<a name="l00083"></a>00083   }
<a name="l00084"></a>00084 
<a name="l00085"></a>00085 
<a name="l00086"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a1e5ef9b8da87d1b412c348ad813d0267">00086</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a1e5ef9b8da87d1b412c348ad813d0267">PointsToTrack::computeDescriptors</a>( )
<a name="l00087"></a>00087   {
<a name="l00088"></a>00088     P_MUTEX(worker_exclusion);
<a name="l00089"></a>00089     <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a086c4acf6884db7487eb05f9c3d996a3">impl_computeDescriptors_</a>();
<a name="l00090"></a>00090     V_MUTEX(worker_exclusion);
<a name="l00091"></a>00091   }
<a name="l00092"></a>00092 
<a name="l00093"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a6ac0b2e69bb0fa51af529ec395fd0df7">00093</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a6ac0b2e69bb0fa51af529ec395fd0df7">PointsToTrack::addKeypoints</a>( std::vector&lt;cv::KeyPoint&gt; keypoints,cv::Mat descriptors<span class="comment">/*=cv::Mat( )*/</span>,<span class="keywordtype">bool</span> computeMissingDescriptor<span class="comment">/*=false*/</span> )
<a name="l00094"></a>00094   {
<a name="l00095"></a>00095     <span class="comment">//add the keypoints to the end of our points vector:</span>
<a name="l00096"></a>00096     this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>.insert( this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>.end( ),keypoints.begin( ),keypoints.end( ) );
<a name="l00097"></a>00097 
<a name="l00098"></a>00098 
<a name="l00099"></a>00099     cv::KeyPointsFilter::runByKeypointSize( <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>,
<a name="l00100"></a>00100       std::numeric_limits&lt;float&gt;::epsilon( ) );
<a name="l00101"></a>00101 
<a name="l00102"></a>00102     <span class="keywordflow">if</span>( !computeMissingDescriptor )
<a name="l00103"></a>00103     {
<a name="l00104"></a>00104       <span class="keywordflow">if</span>( !<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adcbf3783bdf4a2a1d3e10c4b74224899">descriptors_</a>.empty( ) )
<a name="l00105"></a>00105       {
<a name="l00106"></a>00106         Mat newDescriptors( this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>.size( ), this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adcbf3783bdf4a2a1d3e10c4b74224899">descriptors_</a>.cols,
<a name="l00107"></a>00107           this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adcbf3783bdf4a2a1d3e10c4b74224899">descriptors_</a>.type( ) );
<a name="l00108"></a>00108         newDescriptors( 
<a name="l00109"></a>00109           cv::Rect( 0, 0, this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adcbf3783bdf4a2a1d3e10c4b74224899">descriptors_</a>.cols,this-&gt;descriptors_.rows ) ) = 
<a name="l00110"></a>00110           this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adcbf3783bdf4a2a1d3e10c4b74224899">descriptors_</a>;
<a name="l00111"></a>00111 
<a name="l00112"></a>00112         newDescriptors( cv::Rect( 0, this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adcbf3783bdf4a2a1d3e10c4b74224899">descriptors_</a>.rows,
<a name="l00113"></a>00113           this-&gt;descriptors_.cols,descriptors.rows ) ) = descriptors;
<a name="l00114"></a>00114 
<a name="l00115"></a>00115         this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adcbf3783bdf4a2a1d3e10c4b74224899">descriptors_</a>=newDescriptors;
<a name="l00116"></a>00116       }
<a name="l00117"></a>00117     }
<a name="l00118"></a>00118     <span class="keywordflow">else</span>
<a name="l00119"></a>00119     {
<a name="l00120"></a>00120       this-&gt;<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a1e5ef9b8da87d1b412c348ad813d0267">computeDescriptors</a>( );
<a name="l00121"></a>00121     }
<a name="l00122"></a>00122   }
<a name="l00123"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adda3cb43ad421e89b8ddfe24f1c30b30">00123</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adda3cb43ad421e89b8ddfe24f1c30b30">PointsToTrack::printPointsOnImage</a>( <span class="keyword">const</span> Mat &amp;image, Mat&amp; outImg, <span class="keyword">const</span> Scalar&amp; color<span class="comment">/*=Scalar::all( -1 )*/</span>, <span class="keywordtype">int</span> flags<span class="comment">/*=DrawMatchesFlags::DEFAULT*/</span> )<span class="keyword"> const</span>
<a name="l00124"></a>00124 <span class="keyword">  </span>{
<a name="l00125"></a>00125     <span class="keywordflow">if</span>( outImg.empty( ) )
<a name="l00126"></a>00126       outImg=image.clone( );
<a name="l00127"></a>00127     cv::drawKeypoints( image, <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>, outImg, color, flags );
<a name="l00128"></a>00128   }
<a name="l00129"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#aaae603d73a658ed0b4d2c82463372c3b">00129</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#aaae603d73a658ed0b4d2c82463372c3b">PointsToTrack::read</a>( <span class="keyword">const</span> cv::FileNode&amp; node, <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html" title="This class can be used to store informations about point and features. This is an abstract class: you...">PointsToTrack</a>&amp; points )
<a name="l00130"></a>00130   {
<a name="l00131"></a>00131     std::string myName=node.name( );
<a name="l00132"></a>00132     <span class="keywordflow">if</span>( myName != <span class="stringliteral">&quot;PointsToTrack&quot;</span> )
<a name="l00133"></a>00133       <span class="keywordflow">return</span>;<span class="comment">//this node is not for us...</span>
<a name="l00134"></a>00134     cv::FileNode node_keypoints = node[ <span class="stringliteral">&quot;keypoints&quot;</span> ];
<a name="l00135"></a>00135     <span class="keywordflow">if</span>( node_keypoints.empty( ) )
<a name="l00136"></a>00136       CV_Error( CV_StsError, <span class="stringliteral">&quot;PointsToTrack FileNode is not correct!&quot;</span> );
<a name="l00137"></a>00137 
<a name="l00138"></a>00138     cv::FileNodeIterator it = node_keypoints.begin( ), it_end = node_keypoints.end( );
<a name="l00139"></a>00139     <span class="keywordflow">while</span>( it != it_end )
<a name="l00140"></a>00140     {
<a name="l00141"></a>00141       KeyPoint kpt;
<a name="l00142"></a>00142       it &gt;&gt; kpt.pt.x &gt;&gt; kpt.pt.y &gt;&gt; kpt.size &gt;&gt; kpt.angle &gt;&gt; kpt.response &gt;&gt; kpt.octave &gt;&gt; kpt.class_id;
<a name="l00143"></a>00143       points.<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>.push_back( kpt );
<a name="l00144"></a>00144       <span class="comment">//it++ is not needed as the &gt;&gt; operator increment automatically it!</span>
<a name="l00145"></a>00145     }
<a name="l00146"></a>00146 
<a name="l00147"></a>00147     cv::FileNode node_descriptors = node[ <span class="stringliteral">&quot;descriptors&quot;</span> ];
<a name="l00148"></a>00148     <span class="keywordflow">if</span>( node_descriptors.empty( ) )
<a name="l00149"></a>00149       CV_Error( CV_StsError, <span class="stringliteral">&quot;PointsToTrack FileNode is not correct!&quot;</span> );
<a name="l00150"></a>00150     node_descriptors &gt;&gt; points.<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adcbf3783bdf4a2a1d3e10c4b74224899">descriptors_</a>;
<a name="l00151"></a>00151 
<a name="l00152"></a>00152     CV_Assert( points.<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adcbf3783bdf4a2a1d3e10c4b74224899">descriptors_</a>.rows == points.<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>.size() );
<a name="l00153"></a>00153 
<a name="l00154"></a>00154     <span class="comment">//as the loaded PointsToTrack can&#39;t recompute the descriptors_, set the nbworkers</span>
<a name="l00155"></a>00155     <span class="comment">//to a high value (this will disable free_descriptors to release descriptor ;)</span>
<a name="l00156"></a>00156     points.<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a52d852bc3fa39c952405c55a8d1e378f">nb_workers_</a> = 1e5;
<a name="l00157"></a>00157 
<a name="l00158"></a>00158     cv::FileNode node_colors = node[ <span class="stringliteral">&quot;colors&quot;</span> ];
<a name="l00159"></a>00159     <span class="keywordflow">if</span>( !node_colors.empty( ) )
<a name="l00160"></a>00160     {
<a name="l00161"></a>00161       cv::FileNodeIterator it = node_colors.begin( ), it_end = node_colors.end( );
<a name="l00162"></a>00162       <span class="keywordflow">while</span>( it != it_end )
<a name="l00163"></a>00163       {
<a name="l00164"></a>00164         <span class="keywordtype">int</span> color;
<a name="l00165"></a>00165         it &gt;&gt; color;
<a name="l00166"></a>00166         points.<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#ae34562f2590efe81f5ce137ef011bd00">RGB_values_</a>.push_back( color );
<a name="l00167"></a>00167         <span class="comment">//it++ is not needed as the &gt;&gt; operator increment automatically it!</span>
<a name="l00168"></a>00168       }
<a name="l00169"></a>00169     }
<a name="l00170"></a>00170   };
<a name="l00171"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a4659d15437d115ece00feb5335923d50">00171</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a4659d15437d115ece00feb5335923d50">PointsToTrack::write</a>( cv::FileStorage&amp; fs, <span class="keyword">const</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html" title="This class can be used to store informations about point and features. This is an abstract class: you...">PointsToTrack</a>&amp; keypoints )
<a name="l00172"></a>00172   {
<a name="l00173"></a>00173     <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html" title="This class can be used to store informations about point and features. This is an abstract class: you...">PointsToTrack</a> ppt = keypoints;
<a name="l00174"></a>00174     <span class="comment">//as we want to save them, compute keypoints and descriptor:</span>
<a name="l00175"></a>00175     ppt.<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a9f310ef736a0494457ee9f2193b8b986">computeKeypointsAndDesc</a>();
<a name="l00176"></a>00176 
<a name="l00177"></a>00177     fs &lt;&lt; <span class="stringliteral">&quot;{&quot;</span> &lt;&lt; <span class="stringliteral">&quot;PointsToTrack&quot;</span> &lt;&lt; <span class="stringliteral">&quot;{&quot;</span>;
<a name="l00178"></a>00178     <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a4659d15437d115ece00feb5335923d50">cv::write</a>( fs, <span class="stringliteral">&quot;keypoints&quot;</span>, ppt.<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a> );
<a name="l00179"></a>00179 
<a name="l00180"></a>00180     fs &lt;&lt; <span class="stringliteral">&quot;descriptors&quot;</span> &lt;&lt; ppt.<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#adcbf3783bdf4a2a1d3e10c4b74224899">descriptors_</a>;
<a name="l00181"></a>00181     fs &lt;&lt; <span class="stringliteral">&quot;colors&quot;</span> &lt;&lt;<span class="stringliteral">&quot;[:&quot;</span>;
<a name="l00182"></a>00182     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size_max = ppt.<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#ae34562f2590efe81f5ce137ef011bd00">RGB_values_</a>.size( );
<a name="l00183"></a>00183     <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i&lt;size_max; ++i )
<a name="l00184"></a>00184     {
<a name="l00185"></a>00185       fs &lt;&lt; (int)(ppt.<a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#ae34562f2590efe81f5ce137ef011bd00">RGB_values_</a>[i] &amp; 0x00FFFFFF);
<a name="l00186"></a>00186     }
<a name="l00187"></a>00187     fs &lt;&lt; <span class="stringliteral">&quot;]&quot;</span> &lt;&lt; <span class="stringliteral">&quot;}&quot;</span> &lt;&lt; <span class="stringliteral">&quot;}&quot;</span>;
<a name="l00188"></a>00188   }
<a name="l00189"></a>00189 
<a name="l00190"></a><a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a196acc6cc4be60ad141eef597db3787c">00190</a>   <span class="keywordtype">void</span> <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a196acc6cc4be60ad141eef597db3787c">PointsToTrack::getKeyMatches</a>( <span class="keyword">const</span> std::vector&lt;TrackOfPoints&gt;&amp; matches,
<a name="l00191"></a>00191     <span class="keywordtype">int</span> otherImage, std::vector&lt;cv::Point2f&gt;&amp; pointsVals )<span class="keyword"> const</span>
<a name="l00192"></a>00192 <span class="keyword">  </span>{
<a name="l00193"></a>00193     <span class="comment">//for each points:</span>
<a name="l00194"></a>00194     vector&lt;TrackOfPoints&gt;::size_type key_size = matches.size( );
<a name="l00195"></a>00195     vector&lt;TrackOfPoints&gt;::size_type i;
<a name="l00196"></a>00196 
<a name="l00197"></a>00197     <span class="keywordflow">for</span> ( i=0; i &lt; key_size; i++ )
<a name="l00198"></a>00198     {
<a name="l00199"></a>00199       <span class="keyword">const</span> <a class="code" href="class_opencv_sf_m_1_1_track_of_points.html" title="This class store the track of keypoints. A track is a connected set of matching keypoints across mult...">TrackOfPoints</a> &amp;track = matches[ i ];
<a name="l00200"></a>00200 
<a name="l00201"></a>00201       <span class="keywordflow">if</span>( track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#aea06a066b4be5fa2ff5ef09cea7fb745">containImage</a>( <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#aa1ad5a647af1dd6583dbd780e94c089c" title="index of frame when available">corresponding_image_</a> ) &amp;&amp;
<a name="l00202"></a>00202         track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#aea06a066b4be5fa2ff5ef09cea7fb745">containImage</a>( otherImage ) )
<a name="l00203"></a>00203       {
<a name="l00204"></a>00204         <span class="keyword">const</span> KeyPoint &amp;kp = <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#a08c9523080571e71e30b11a2f8b9c6b9">keypoints_</a>[ track.<a class="code" href="class_opencv_sf_m_1_1_track_of_points.html#af61c242e5fabb09d85305426ab46307c">getPointIndex</a>( <a class="code" href="class_opencv_sf_m_1_1_points_to_track.html#aa1ad5a647af1dd6583dbd780e94c089c" title="index of frame when available">corresponding_image_</a> ) ];
<a name="l00205"></a>00205         pointsVals.push_back( cv::Point2f( kp.pt.x,kp.pt.y ));
<a name="l00206"></a>00206       }
<a name="l00207"></a>00207     }
<a name="l00208"></a>00208   }
<a name="l00209"></a>00209 }
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Sun Aug 21 2011 16:45:52 for GSoC2011SfM by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
